package com.zhai.cloud.home.job;

import com.netflix.discovery.util.StringUtil;
import com.zhai.cloud.common.constant.LogConstant;
import lombok.extern.slf4j.Slf4j;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;
import org.springframework.stereotype.Component;

/**
 * @author Created by 翟凤玺
 * @package com.zhai.cloud.home.job
 * @project-name zhai-cloud
 * @description 主页任务
 * @create-datetime 2019-8-6 14:11
 */
@Slf4j
@Component
@DisallowConcurrentExecution
public class HomeJob extends QuartzJobBean {

    private static final String BUSINESS_NAME = "【主页 任务】";
    private static final String METHOD_JOB = "（执行任务）";

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        JobDetail jobDetail = jobExecutionContext.getJobDetail();
        String jobName = jobDetail.getKey().getName();
        String jobGroupName = jobDetail.getKey().getGroup();
        log.info(StringUtil.join(BUSINESS_NAME, LogConstant.SERVICE, METHOD_JOB, LogConstant.IN, "taskCode:", jobName, " groupName:", jobGroupName));
        log.info(StringUtil.join(BUSINESS_NAME, LogConstant.SERVICE, METHOD_JOB, LogConstant.RESULT, LogConstant.SUCCESS));
    }
}